//
//  ReturnMoneyApplyVC.m
//  MRBang
//
//  Created by 铅笔 on 15/12/16.
//  Copyright © 2015年 杭州易网新科技. All rights reserved.
//

#import "ReturnMoneyApplyVC.h"
#import "ReturnMoneyApplyRecordDetailVC.h"

#import "ReturnMoneyApplyCell.h"

@interface ReturnMoneyApplyVC ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) NSMutableArray *mutableArray_data;//存放所有数据

@property (nonatomic,strong) UIView *view_topThreLabel;//头部三个label

@end

@implementation ReturnMoneyApplyVC

- (NSMutableArray *)mutableArray_data
{
    if (!_mutableArray_data) {
        _mutableArray_data = [[NSMutableArray alloc] init];
    }
    return _mutableArray_data;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"还款申请纪录";
    
    //创建子视图
    [self initWithAllSubviews];
}

- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.tabBar.hidden = YES;
}

#pragma mark ---- 创建子视图
- (void) initWithAllSubviews
{
    
    [self initWithTopThreeLabel];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,self.view_topThreLabel.frame.size.height+self.view_topThreLabel.frame.origin.y, kScreenWidth, kScreenHeight-99)];
    [self.view addSubview:self.tableView];
    
    self.tableView.dataSource = self;
    self.tableView.delegate = self;

    self.tableView.showsVerticalScrollIndicator = NO;
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
}

//申请银行 申请日期 状态
- (void) initWithTopThreeLabel
{
    self.view_topThreLabel = [[UIView alloc] initWithFrame:CGRectMake(0,64, kScreenWidth, 35)];
    [self.view addSubview:self.view_topThreLabel];
    
   
    NSArray *array_titleLabel = @[@"申请银行",@"申请日期",@"状态"];
    
    for (int i=0; i<3; i++) {
        
        UILabel *label_titleText = [[UILabel alloc] init];
        [self.view_topThreLabel addSubview:label_titleText];
        label_titleText.textColor = RXDColor(102, 102, 102);
        
        CGFloat labelX = kScreenWidth/3;
        label_titleText.frame = CGRectMake(labelX*i,5, labelX, 30);
        label_titleText.text = array_titleLabel[i];
        label_titleText.textAlignment = NSTextAlignmentCenter;
        label_titleText.font = [UIFont systemFontOfSize:14];
    }
    
    //横线
    UIView *view_line  = [[UIView alloc] initWithFrame:CGRectMake(0,34, kScreenWidth, 1.0)];
    [self.view_topThreLabel addSubview:view_line];
    view_line.backgroundColor = [UIColor colorWithRed:249.0/255.0 green:249.0/255.0 blue:249.0/255.0 alpha:1.0];
}

#pragma mark --- UITableViewDataSource
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 7;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *ID = @"cellReturnMoney";
    ReturnMoneyApplyCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    if (cell == nil) {
        cell = [[ReturnMoneyApplyCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    ReturnMoneyApplyRecordDetailVC *returnMoneyDetail = [[ReturnMoneyApplyRecordDetailVC alloc] init];
    [self.navigationController pushViewController:returnMoneyDetail animated:NO];

}

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 160;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
}

@end
